
import os
import sys
d = os.path.dirname(__file__)
parent_path = os.path.dirname(d)
sys.path.append(parent_path)
from ulits import fstool
import time
import xlrd
import xlwt
from order import gener

def buyer_pay(buyer_id):
    A = ['微信' ,'支付宝' ,'返回' ,'退出']
    excel_g = fstool.Excel(parent_path+'/data'+'/goods.xls')
    gross_price = 0 
    for i in excel_g.read_all_data('goods'):
        if i[1] == buyer_id:
            gross_price += int(i[-1]) * int(i[-2])
    print('--'*40)
    print('总需支付：%d元'%gross_price)
    print('--'*40)
    while True:
        pay_mode = fstool.show(A) 
        if pay_mode == '1' or pay_mode == '2':
            print('支付成功！')
            c = gener.Gener_ord(buyer_id,True)
            c.gener()           
        elif pay_mode == '3':
            return True
        elif pay_mode == '4':
            exit('退出')
        else:
            print('输入错误！')


if __name__ == '__main__':
    globl = buyer_pay('12345678901')